package com.gcsoftware.web.utils;

import com.gcsoftware.web.response.*;
/**
 * Created by qs on 2018/4/4.
 * 返回结果对象辅助类
 */
public class ResultUtils {

    public static ResultRsp success() {
        return success(null);
    }

    public static ResultRsp success(Object obj) {
        return result(0,"成功",obj);
    }

    public static ResultRsp success(String msg) {
        return result(0,msg,null);
    }

    public static ResultRsp success(String msg,Object object) {
        return result(0,msg,object);
    }


    public static ResultRsp success(int code, String msg) {
        return result(code,msg,null);
    }

    private static ResultRsp success(int code, String msg, Object object) {
        return result(code,msg,object);
    }

    public static ResultRsp error() {
        return error(null);
    }

    public static ResultRsp error(Object obj) {
        return result(500,"失败",obj);
    }

    public static ResultRsp error(String msg) {
        return result(500,msg,null);
    }

    public static ResultRsp error(String msg,Object object) {
        return result(500,msg,object);
    }


    public static ResultRsp error(int code, String msg) {
        return result(code,msg,null);
    }

    private static ResultRsp error(int code, String msg, Object object) {
        return result(code,msg,object);
    }
    private static ResultRsp result(int code, String msg, Object object) {
        ResultRsp result = new ResultRsp();
        result.setCode(code);
        result.setMsg(msg);
        result.setData(object);
        return result;
    }
}
